package com.azt.novel.resource.controller;


import com.azt.novel.common.resp.RestResp;
import com.azt.novel.resource.dto.resp.ImgVerifyCodeRespDto;
import com.azt.novel.resource.service.IResourceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/front/resource")
public class ResourceController {

    @Resource
    private IResourceService iResourceService;

    /**
     * 图片上传接口
     */
    @Operation(summary = "图片上传接口")
    @PostMapping("/image")
    RestResp<String> uploadImage(
            @Parameter(description = "上传文件") @RequestParam("file") MultipartFile file) {
        return iResourceService.uploadImage(file);
    }

    /**
     * 获取图片验证码接口
     */
    @Operation(summary = "获取图片验证码接口")
    @GetMapping("/img_verify_code")
    public RestResp<ImgVerifyCodeRespDto> getImgVerifyCode() throws Exception{
        return iResourceService.getImgVerifyCode();
    }
}

